package com.praxinfosystems.sarthak.dao;

import javax.annotation.Resource;

import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.stereotype.Repository;

import com.praxinfosystems.sarthak.daoUtil.UserRowMapper;
import com.praxinfosystems.sarthak.domain.User;

@Repository("userRepository")
public class UserDaoImpl implements UserDao{

	@Resource(name="jdbcTemplate")
	private SimpleJdbcTemplate jdbcTemplate; 
	
	@Override
	public User getUserDetail(String userId) {
		try{
			User user=jdbcTemplate.queryForObject("select * from user where user_id=?",new UserRowMapper(),userId);
			System.out.println("user role is :"+user.getRole());
			return user;
		}catch(EmptyResultDataAccessException e){
			e.getMessage();
			return null;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	
	}

}
